-module(list_pattern).

-include_lib("ect/include/ect.hrl").

-import_class(pattern1).
-import_class(pattern2).
-import_class(pattern3).

-export([dotest/0]).

dotest() ->
    okay = non_clause_test(),
    X1 = #pattern3{c = ["p", "a", "s", "s"]},
    Z = list_to_atom(process(X1)),
    X2 = #pattern3{a = Z},
    process2(X2).

process(X = #pattern2{c = [Item|List]}) ->
    Item++process(X#pattern2{c = List});
process(X = #pattern2{c = []}) ->
    [].

process2(#pattern3{a = {_, X}}) ->
    X;
process2(#pattern3{a = X}) ->
    X.

non_clause_test() ->
    P = #pattern3{d = [aaa, bbb, okay, ccc]},
    #pattern3{d = [_,_,X|_]} = P,
    X.